import BuffUtil from '@/BuffUtil';
import BuffCommon from 'code/Core/Common/BuffCommon';
import SelectCommon from 'code/Core/Common/SelectCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 勇气怒吼
 **/
export default class ZS_HowlOfCourage extends AbilityBase {
    static instance: ZS_HowlOfCourage;
    buffType: AppBuffType = {
        id: 'buff_ZS_HowlOfCourage',
        art: this.art,
        name: this.abilityName,
        ubertip: '攻击力与攻击速度得到强化',
        isDebuff: false,
        dur: 12,
        attribute: {},
        targetAttach: 'overhead',
        targetArt: 'Abilities\\Spells\\NightElf\\BattleRoar\\RoarTarget.mdl',
    };
    constructor(id: string = 'Ayqh') {
        super(id);
        ZS_HowlOfCourage.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        let us = SelectCommon.getAllyUnitInRange(source, 800);
        let lv = this.getAbilityLevel(source);
        for (let u of us) {
            // let buff = BuffUtil.addBuff(u, this.buffType.id, source);
            // buff.attribute.attack = 10 + 15 * lv;
            // buff.attribute.attackSpd_p = 0.1 + 0.1 * lv;
            BuffCommon.addBuff({
                target: u,
                caster: source,
                buffTypeId: this.buffType.id,
                ablityId: this.id,
                attribute: {
                    attack: 10 + 15 * lv,
                    attackSpd_p: 0.1 + 0.1 * lv,
                },
            });
        }
        DestroyEffect(AddSpecialEffectTarget('Abilities\\Spells\\NightElf\\BattleRoar\\RoarCaster.mdl', source, 'origin'));
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
